<?php
/**
 * Created by PhpStorm.
 * User: linyh
 * Date: 2015/8/8
 * Time: 21:46
 */

class user extends Activity {
    function indexTask(){
        $cms=CmsView::init();
        $url=WebRouter::init()->getAction("login");
        $cms->loginScene($url);
    }

    function loginTask($user, $pass){
        $userModule=UserModule::init();
        $message=$userModule->login($user, $pass);
        if($message->state!=DataMessage::STATE_SUCCESS){
            View::displayDataMessage($message);
            return;
        }
        $userInfo=$userModule->getLoginInfo();
        if($userInfo['type']!='admin'){
            View::displayDataMessage("抱歉，您没有管理员权限");
            return;
        }
        header("Location:".WebRouter::init()->getPage("article","table"));
        return;
    }

    function loginoutTask(){
        $userModule=UserModule::init();
        $userModule->loginout();
        $url=WebRouter::init()->getPage("user","index");
        View::displayAsTips($url,"退出成功");
    }
}